package com.builder.demo00;

import java.util.ArrayList;
import java.util.List;

/**
 * 提取出来的导演类:
 * 1.延迟了产品类的构造(每个具体产品业务内部各个零件之间的关系已经不再由具体产品负责)
 * 2.可以根据客户需求灵活组装具体产品的零件
 */
public class Director {
    private List<String> sequence = new ArrayList<>();
    private CarBuilder motoCarBuilder = new MotoCarBuilder();
    private CarBuilder suvCarBuilder = new SuvCarBuilder();

    // 建造摩托车
    public MotoCar getMotoCar(){
        this.sequence.clear();
        this.sequence.add("start");
        this.sequence.add("stop");
        this.motoCarBuilder.setSequence(this.sequence);
        return (MotoCar) this.motoCarBuilder.getCar();
    }

    // 建造SUV
    public SuvCar getSuvCar(){
        this.sequence.clear();
        this.sequence.add("engine boom");
        this.sequence.add("start");
        this.sequence.add("stop");
        this.suvCarBuilder.setSequence(this.sequence);
        return (SuvCar) this.suvCarBuilder.getCar();
    }

    // 建造各种车子

}
